package com.conv.shop.business.service;


import com.conv.shop.business.domain.AdminInfo;
import com.conv.shop.business.domain.AdminInfoExample;
import com.conv.shop.business.mapper.AdminInfoMapper;
import jakarta.annotation.Resource;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Objects;

@Service
public class AdminService {
    @Resource
   private AdminInfoMapper adminInfoMapper;

    /**
     * 管理员登录
     * @param adminInfo
     * @return boolean
     */
    public boolean adminLogin(AdminInfo adminInfo) {
        AdminInfoExample example = new AdminInfoExample();
        example.createCriteria().andAdminNameEqualTo(adminInfo.getAdminName());
        List<AdminInfo> adminInfos = adminInfoMapper.selectByExample(example);
        return !adminInfos.isEmpty() && Objects.equals(adminInfo.getAdminPassword(), adminInfos.get(0).getAdminPassword());
    }

    /**
     * 商家禁用/启用
      * @param adminInfo
     * @return boolean
     */
    public boolean disableEnableStore(AdminInfo adminInfo) {
        AdminInfoExample example = new AdminInfoExample();
        AdminInfoExample.Criteria criteria = example.createCriteria().andAdminIdEqualTo(adminInfo.getAdminId());
        return true;
    }
}
